// import axios from "axios";
// import axios from "axios";
import { request } from "./utils";

export function listAllRooms() {
  return request({
    url: "/hotel/rooms/listAll",
    method: "get"
  });
}
export function listRoomsPrice(params?: QueryParams) {
  return request({
    url: "/hotel/rooms/pageWithPrice",
    method: "get",
    params: params
  });
}
export function getPriceTotal(params: RoomCheckInForm) {
  return request({
    url: "/hotel/sale/getTotal",
    method: "get",
    params: params
  });
}
export function addCheckInfo(data: RoomCheckInForm) {
  return request({
    url: "/hotel/sale/stay",
    method: "post",
    data: data
  });
}
export function getRoomCustomerInfo(roomNumber: string) {
  return request({
    url: "/hotel/rooms/roomDetails/" + roomNumber,
    method: "get"
  });
}
export function getDepositByRoomNumber(roomNumber) {
  return request({
    url: "/hotel/sale/getDeposit/" + roomNumber,
    method: "get"
  });
}
export function wechatPay(data: RoomCheckInForm) {
  return request({
    url: "/hotel/sale/wechat/pay",
    method: "post",
    data: data
  });
}
export function cashPay(data: RoomCheckInForm) {
  return request({
    url: "/hotel/sale/cash/pay",
    method: "post",
    data: data
  });
}

export function getRoomPricePageWithPrice(params?: QueryParams) {
  return request({
    url: "/hotel/rooms/pageWithPrice2",
    method: "get",
    params: params
  });
}
export function getCheckOutStatus(params?: RoomCheckOutStatus) {
  return request({
    url: "/hotel/rooms/getCheckOutStatus",
    method: "get",
    params: params
  });
}
export function roomCheckOut(roomNumber, endDate) {
  return request({
    url: "/hotel/rooms/checkOut",
    method: "put",
    headers: {
      "Content-Type": "application/json" // 明确指定JSON格式
    },
    data: {
      roomNumber,
      endDate // 包装成JSON对象
    }
  });
}
export function getAllCheckOutStatus(date) {
  return request({
    url: "/hotel/rooms/getAllCheckOutStatus",
    method: "get",
    params: {
      date
    }
  });
}
export function getQrCodeHotel() {
  return request({
    url: "/hotel/sale/alipay/getQrCode",
    method: "get",
    params: {
      t: Date.now()
    }
  });
}
interface QueryParams {
  pageNum: number;
  pageSize: number;
  floor: number;
  status: string;
  roomTypeId: number;
  date: string;
  startDate?: string;
  endDate?: string;
}
//房间及房型合并数据
interface RoomPriceDTO {
  id: number;
  roomNumber: string;
  roomTypeId: number;
  status: string;
  floor: number;
  area: number;
  windows: string;
  towards: string;
  description: string;
  name: string;
  image: string;
  type: string;
  level: string;
  beds: number;
  basicPrice: number;
  finalPrice: number;
}
//房间入住表单
interface RoomCheckInForm {
  roomNumber?: string;
  contact?: string;
  phone?: string;
  startDate: string;
  days: number;
  information?: string;
  // infoList?: CustomerInfo[];
}
interface RoomCheckOutStatus {
  roomNumber: string;
  date: string;
}
interface CustomerInfo {
  customerName: string;
  idCard: string;
}

export type {
  CustomerInfo,
  QueryParams,
  RoomPriceDTO,
  RoomCheckInForm,
  RoomCheckOutStatus
};
